'''
Created on May 8, 2012
TC ID: Ecom_5044
Desc: Kiem thu chuc nang tao mot du an moi
@author: lavang
'''
import unittest
import time
from HTMLTestRunner import HTMLTestRunner
from Functions.globalFunc import preCondition, readData, endCondition
from Functions.loginPageFunc import login
from Functions.lessonInformationFunc import clickOnLesson
from Functions.projectFunc import clickOnProjects, clickOnAddProject, addProject,\
    clickOnLinkProjects, isProjectAddedSuccessfully

username=readData("username",index=2)
password=readData("password",index=2)
tm_lesson=readData("lessonName",index=3)
tm_project='project1'
tm_desc='project description'
class Ecom_5044(unittest.TestCase):


    def setUp(self):
        preCondition(self)

    def test_Ecom_5044(self):
        print "Buoc 1: Dang nhap website"
        login(self,username,password)
        
        print "Buoc 2: Click vao mot bai hoc"
        clickOnLesson(self,tm_lesson)
        
        print "Buoc 3: Click vao 'Project' "
        clickOnProjects(self)
        
        print "Buoc 4: Click 'Add project' "
        clickOnAddProject(self)
        
        print "Buoc 5: Tao mot du an"
        addProject(self,tm_project,'08','Jun','2013','03','03',tm_desc)
        
        print "Buoc 6: Quay ve trang Project"
        clickOnLinkProjects(self)
        
        print "Buoc 7: Xac nhan tao du an thanh cong"
        self.assertTrue(isProjectAddedSuccessfully(self,tm_project), "Failed!")
        print "Passed! Tao du an thanh cong"
        
        
    def tearDown(self):
        endCondition(self)


if __name__ == "__main__":
    #import sys;sys.argv = ['', 'Test.testName']
    testSuite = unittest.TestSuite()
    suite = unittest.TestLoader().loadTestsFromTestCase(Ecom_5044)
    dateTime = time.strftime('%Y%m%d_%H_%M_%S')
    buf = file("../../Report/TestResults" + "_" + dateTime + ".html",'wb')
    runner = HTMLTestRunner(
                    stream=buf,
                    title='Test Results',
                    description='Kiem thu chuc nang tao mot du an'
                    )
    runner.run(suite)